<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>현재 장애</title>
	<jsp:include page="/WEB-INF/views/common/header.jsp" />
	<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}" />/resources/common/js/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}" />/resources/common/js/knockout-3.0.0.js"></script>
	<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}" />/resources/common/js/sockjs-0.3.4.min.js" ></script>
	<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}" />/resources/common/js/stomp.js" ></script>
	<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}" />/resources/js/remote/WebSocketController.js" ></script>
	<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}" />/resources/common/js/EventBus.js" ></script>
	<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}" />/resources/js/Constants.js" ></script>
	<%-- URL for the STOMP end point for registering a stomp client--%>
	<c:url value="/alarmmessages" var="socketDest" />

	<script type="text/javascript">
		// Runs this code only when the DOM (all elements) are ready
		$(document).ready(function() {
			connect();
		});
		
		function connect() {
			wsController = new WebSocketController();
			wsController.connect('${socketDest}');
			
			EventBus.addEventListener(EventType.ALARM_RECEIVED, receiveAlarm, null);
		}
		
		function receiveAlarm(event, alarmMsg) {
			alert("receiveAlarm event:" + event);
			alert("receiveAlarm alarmMsg:" + alarmMsg);
		}

	</script>
</head>
<body>
	<table>
		<tr>
			<th>등급</th>
			<th>알람ID</th>
			<th>위치</th>
			<th>메시지</th>
			<th>발생시간</th>
			<th>확인자</th>
			<th>확인시간</th>
		</tr>
	</table>
</body>
</html>